<?php

namespace Emoney\UserBundle\Entity;

use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="fos_user")
 */
class User extends BaseUser
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    
    protected $id;
    
    /**
     * @ORM\ManyToOne(targetEntity="Group")
     * @ORM\JoinColumn(name="group_id", referencedColumnName="id")
     */
    
    protected $group;
    
    /**
     * @ORM\OneToMany(targetEntity="Emoney\EpayBundle\Entity\Sitename", mappedBy="User")
     */
    protected $sitenames;
	
    /**
     * @var string  $phone
     *
     * @ORM\Column(name="phone", type="string", length=30)
     */
	 
    protected $phone;
    
    /**
     * @var string $ville
     * 
     * @ORM\Column(name="ville", type="string", length=255)
     */
    protected $ville;
    
    /**
     * @var string $adresse
     * 
     * @ORM\Column(name="adresse", type="string", length=255)
     */
    protected $adresse;
    
    /**
     * @var string $zipcode
     * 
     * @ORM\Column(name="zipcode", type="string", length=255)
     */
    protected $zipcode;
    
    /**
     * @ORM\OneToMany(targetEntity="Emoney\EpayBundle\Entity\Retreives", mappedBy="User")
     */
    protected $retreives;
    
    /**
     * @var float $avoirs
     * 
     * @ORM\Column(name="avoirs", type="float", nullable=true)
     */
    protected $avoirs;
	
    public function __construct()
    {
        parent::__construct();
        // your own logic
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set group
     *
     * @param Emoney\UserBundle\Entity\Group $group
     */
    public function setGroup(\Emoney\UserBundle\Entity\Group $group)
    {
        $this->group = $group;
    }

    /**
     * Get group
     *
     * @return Emoney\UserBundle\Entity\Group 
     */
    public function getGroup()
    {
        return $this->group;
    }

    /**
     * Add sitenames
     *
     * @param Emoney\UserBundle\Entity\Sitename $sitenames
     */
    public function addSitename(\Emoney\EpayBundle\Entity\Sitename $sitenames)
    {
        $this->sitenames[] = $sitenames;
    }

    /**
     * Get sitenames
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getSitenames()
    {
        return $this->sitenames;
    }

    /**
     * Set phone
     *
     * @param string $phone
     */
    public function setPhone($phone)
    {
        $this->phone = $phone;
    }

    /**
     * Get phone
     *
     * @return string 
     */
    public function getPhone()
    {
        return $this->phone;
    }

    /**
     * Set ville
     *
     * @param string $ville
     */
    public function setVille($ville)
    {
        $this->ville = $ville;
    }

    /**
     * Get ville
     *
     * @return string 
     */
    public function getVille()
    {
        return $this->ville;
    }

    /**
     * Set adresse
     *
     * @param string $adresse
     */
    public function setAdresse($adresse)
    {
        $this->adresse = $adresse;
    }

    /**
     * Get adresse
     *
     * @return string 
     */
    public function getAdresse()
    {
        return $this->adresse;
    }

    /**
     * Set zipcode
     *
     * @param string $zipcode
     */
    public function setZipcode($zipcode)
    {
        $this->zipcode = $zipcode;
    }

    /**
     * Get zipcode
     *
     * @return string 
     */
    public function getZipcode()
    {
        return $this->zipcode;
    }
	
    /**
     * Returns the user roles
     *
     * Implements SecurityUserInterface
     *
     * @return array The roles
     */
    public function getRoles()
    {
        $roles = $this->getGroup()->getRoles() ;       

        // we need to make sure to have at least one role
        $roles[] = static::ROLE_DEFAULT;

        return array_unique($roles);
    }
    
    /**
     * Set avoirs
     *
     * @param float avoirs
     */
    public function setAvoirs($avoirs)
    {
        $this->avoirs = $avoirs;
    }
    
    /**
     * Get avoirs
     *
     *  @return float 
     */
    public function getAvoirs()
    {
        return $this->avoirs;
    }
}